<?
/*Created by : M.Ansar Basha
[created : 02/24/2007, 04:02:48 PM]
 Description: Bank Realization Certificate Details Page
*/

include("../../includes/global_files/tables.inc");
include(DOCINCLUDES."global_files/global_html.inc");
include(DOCINCLUDES."global_files/global_form.inc");//
include(DOCINCLUDES."global_files/global_report.inc");
include(DOCINCLUDES."global_files/tables.inc");
include(DOCINCLUDES."global_files/global_pgsql.inc");
include(DOCINCLUDES."global_files/global_functions.inc");



$page=new cPage;
$page->header_path="../../";

$form=new cForm();
$db=new cDatabase($company_id);
$report=new cReport();
$sql=new pgSql();//


if($_GET)
{
$brc_id=$_GET['brc_id'];
}


if(!$brc_id)
{
$db->query="Select max(brc_id) as brc_id from $brc;";
$db->runQuery();
$brc_array=$db->returnArrays();
$brc_no_val=$brc_array[0]['brc_id'];
$brc_id=$brc_no_val;
}

$page->doHeaderHtml();

$db->query="select
brc_id as \"BRC ID\", transaction_id,transaction_type,description as \"Description\", export_promotion as \"Export Promotion Number \",to_char(export_promotion_date,'dd/mm/yyyy') as \"Export Promotion Date \", bill_of_lading as \"Bill of Lading\", to_char(bill_of_lading_date,'dd/mm/yyyy') as \"Bill of Lading Date\",value1 as \"Value1\",value2 as \"Value2\", bill_amount as \"Bill Amount\", freight_amount as \"Freight Amount\", insurance_amount as \"Insurence Amount\", commission_paid as \"Comission Paid\",case when convertable='t' then 'yes' when 'f' then 'No' end as \"Convertable Currency?\", fob_value as \"F.O.B. Value\", bank_ref_no as \"Bank Reference Number \", to_char(date_of_export,'dd/mm/yyyy') as \"Date of Export\", to_char(date_of_realization,'dd/mm/yyyy') as \"Date of Realization\", form_no as \"Form No.\", category_id as \"Catagory type\", sign_name as \"Name \", designation as \"Designation\" from $brc WHERE brc_id=$brc_id;";
$db->runQuery();
$brc_array=$db->returnArrays();
$trans_id=$brc_array[0]['transaction_id'];

if ($brc_array[0]['transaction_type']=='gsp')
{
	$db->query="SELECT distinct(nos_invoice_date) from gsp_item_details where gsp_id=".$trans_id." and nos_invoice_date!='';";
}
elseif ($brc_array[0]['transaction_type']=='coc')
{
  	$db->query="SELECT invoice_no||'/'||invoice_date as nos_invoice_date from certificate_of_origin_commercial where commercial_id=$trans_id;";
}

$db->runQuery();
$inv_detail_array=$db->returnArrays();
$invoice_date=explode('/',$inv_detail_array[0]['nos_invoice_date']);
$brc_array[0]['Invoice Number']=$invoice_date[0];

$brc_array[0]['Invoice Date']=$invoice_date[1];
if (brc_array)
{
echo "<div align=\"center\">";
echo "<a href=\"brc.php\"> BRC Page </a>  || <a href=\"../reports/report_page.php?report_id=5\"> BRC
Report</a> || <a href=\"brc.php?brc_id=$brc_id&action=edit\"> Edit</a> || <a href=\"brc_details.php?brc_id=$brc_id&action=delete\"> Delete </a>";
echo "<div>";
}


	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse; aligin:left;";
	$report->customization["tr_style"]="border-style:none;
border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="Bank Realization Certificate Page Details";
	$report->data=$brc_array;
	echo "<div align=\"center\">";
	$report->setNA();
	$report->doHorizontalTable();
	echo "</div>";
	echo "<BR>";
	echo "<BR>";

	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse;";
	$report->customization["tr_style"]="border-style:none;
	border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="brc Item Details";
	$report->setNA();
	$report->data=$items_array;
	echo "<div align=\"center\">";
	$report->doHorizontalTable();
	echo "</div>";

?>